Skip to content

Design: a framework-agnostic projection store - #123

Merged
agorischek merged 2 commits into
mainfrom
headless-store-design
Nov 21, 2026
Merged

agorischek merged 2 commits into
mainfrom
headless-store-design

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

This is item G4 of the headless-host plan: a design note to agree on before the code. It is documentation only.

The problem

useProjection is the core's whole orchestration, written as about thirty React hooks. So:

  • a Vue, Svelte, Lit or plain-DOM host has to rewrite exactly the part the core calls "the state that must be correct and secure";
  • React hosts get a snapshot (controllerRef) with no subscription;
  • the orchestration can only be tested in a browser.

The proposal

docs/design/proposals/headless-store.md:

  • API:
    • createProjection(options) returns getSnapshot, subscribe, update, the controller's actions unchanged, and destroy;
    • mountStage(element, projection, …) is the stage without React;
    • useProjection becomes a useSyncExternalStore adapter.
  • Composition:
  • Timing: what must run before paint stays before paint. The React adapter updates in a layout effect, and Strict Mode is safe.
  • Six PR-sized steps, each keeping ProjectionController and the browser suites unchanged. Steps 1–4 add node tests for orchestration that only browser specs cover today.

The State machine survey session agreed that I compose the store on its machine package, and that its playback machine is the store's core. Implementation starts after #110, #115 and #122 merge.

A proposal for `createProjection`, a store any framework can subscribe to, with `useProjection` as its React
adapter and `mountStage` as a stage without React, composed from the machine package's playback machine, a
pane-status machine and selectors, in six pull-request-sized steps.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The proposal leaves a Strict Mode lifecycle issue unresolved: cleanup destroys the preserved store instance, while initializer-started activities can leak, requiring side-effect-free construction and restartable activation/deactivation.

1 open issue
What changed in this PR

This documentation-only PR proposes extracting host-core orchestration into a framework-agnostic store, allowing non-React hosts to reuse it while preserving the existing ProjectionController API.

Changes:

  • Defines createProjection, a vanilla-DOM mountStage, and a thin React adapter.
  • Describes composition around settings, playback, pane status, selectors, and selection, building on #110, #115, and #122.
  • Outlines timing requirements and six incremental implementation steps with Node-based orchestration tests.
File Description
docs/​design/​proposals/​headless-store.md Adds the proposed store API, architecture, lifecycle requirements, and migration plan.

Review effort: Balanced

Comment thread docs/design/proposals/headless-store.md Resolved
…troyed in cleanup

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit bcfbdf5 into main Nov 21, 2026
25 checks passed
@agorischek
agorischek deleted the headless-store-design branch November 21, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants